home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / src / novia_internal_commands.c < prev    next >
Text File  |  1999-12-06  |  22KB  |  836 lines

  1. #include <exec/types.h>
  2. #include <pragma/exec_lib.h>
  3. #include <pragma/dos_lib.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <novia/novia_global.h>
  8. #include <novia/novia_misc.h>
  9. #include <novia/novia_registers.h>
  10. #include <novia/novia_portdata.h>
  11. #include <novia/novia_gui.h>
  12. #include <pragma/noviasys_lib.h>
  13.  
  14.  
  15. extern struct PortData *FindClient(ULONG PortID);
  16. extern void EditNRCList(List *);
  17.  
  18.  
  19. extern struct Task *GUITask;
  20. extern struct Task *MainTask;
  21. extern struct GUIFrontend guifrontend;
  22. extern List *client_list;
  23. extern struct NRCServer *nrcserver;
  24.  
  25.  
  26. char StdCommand(ULONG cmdid);
  27.  
  28. char StdCommand(ULONG cmdid)
  29. {
  30.     struct PortData *cport=(PortData *)FindTask(NULL)->tc_UserData;
  31.     struct PortData *mport=(PortData *)MainTask->tc_UserData;
  32.     ULONG ulong,ibm_global_network_ist_scheisse;
  33.     PortData *cport2;
  34.     PortData2 *nc;
  35.     char buffer[100];
  36.     BOOL quit;
  37.     ULONG secs;
  38.     ULONG mics;
  39.     ULONG mics2;
  40.     ULONG progtype;
  41.     if (cport == mport)
  42.         progtype = NOVIA_MAIN;
  43.     else
  44.         progtype = NOVIA_CLIENT;
  45.  
  46.     switch(cmdid)
  47.     {
  48.         case CMD_SUBBOARD_DEL:
  49.             if ((ulong = (ULONG) ndos_delete(cport->argptr)))
  50.             {
  51.                 ioprintf("can't delete %s.\n",cport->argptr);
  52.                 PrintDosError((LONG)ulong);
  53.             }
  54.             else
  55.                 ioprintf("%s deleted.\n",cport->argptr);
  56.  
  57.             return TRUE;
  58.             break;
  59.         case CMD_INFO:
  60.             if ((ulong = (ULONG) ndos_info(cport->argstring[1])))
  61.             {
  62.                 ioprintf("can't rename %s.\n",cport->argptr);
  63.                 PrintDosError((LONG)ulong);
  64.             }
  65.             else
  66.                 ioprintf("%s renamed.\n",cport->argptr);
  67.  
  68.             return TRUE;
  69.             break;
  70.         case CMD_RENAME:
  71.             if ((ulong = (ULONG) ndos_rename(cport->argstring[1],cport->argstring[2])))
  72.             {
  73.                 ioprintf("can't rename %s.\n",cport->argptr);
  74.                 PrintDosError((LONG)ulong);
  75.             }
  76.             else
  77.                 ioprintf("%s renamed.\n",cport->argstring[1]);
  78.             return TRUE;
  79.             break;
  80.         case CMD_POST:
  81.             ioprintf("\nc7Subject:> ");
  82.             Getstring(buffer,0,50,0,0);
  83.             if (strlen(buffer)>=3)
  84.             {
  85. //                VisualEditor("ram:temp");
  86.                 {
  87.                     BPTR mulder;
  88.                     if ((mulder = Open("ram:temp",MODE_OLDFILE)))
  89.                     {
  90.                         Seek(mulder,0,OFFSET_END);
  91.                         if ((ulong = Seek(mulder,0,OFFSET_BEGINNING)))
  92.                         {
  93.                             struct NewItem *newitem;
  94.                             if ((newitem = AllocVec(sizeof(NewItem),MEMF_ANY|MEMF_CLEAR)))
  95.                             {
  96.                                 if ((newitem->text = AllocVec(ulong+1,MEMF_ANY)))
  97.                                 {
  98.                                     if (Read(mulder, newitem->text, ulong))
  99.                                     {
  100.                                         char quit = FALSE;
  101.                                         newitem->ItemType            = ITEMTYPE_MESSAGE;
  102.                                         GetTime(&newitem->CreateDate);
  103.                                         newitem->Protection        = FIBF_READ | FIBF_WRITE | FIBF_EXECUTE | FIBF_DELETE;
  104.                                         newitem->CreateUserIP    = cport->LocalUser.IPNumber;
  105.                                         newitem->FromUser            = cport->LocalUser.IDNumber;
  106.                                         ioprintf("Write as anonymous ? ");
  107.                                         if (Yesno(FALSE,0))
  108.                                         {
  109.                                             newitem->anonymous = TRUE;
  110.                                         }
  111.                                         else
  112.                                         {
  113.                                             ioprintf("Write as alias ? ");
  114.                                             if (Yesno(FALSE,0))
  115.                                             {
  116.                                                 ioprintf("Enter the SENDER's Username [ENTER=YOU]\n:");
  117.                                                 Getstring(newitem->Alias,0,60,0,0);
  118.                                             }
  119.                                         }
  120.                                         strncpy(newitem->Subject,        buffer,70);
  121. //                                        Filename[108]
  122.                                         strncpy(newitem->From,            cport->LocalUser.Handle,sizeof(newitem->From)-1);
  123.                                         strncpy(newitem->FromRealName,    cport->LocalUser.RealName,sizeof(newitem->FromRealName)-1);
  124.                                         while (!quit)
  125.                                         {
  126.                                             ioprintf("Enter the ADDRESS handle [ENTER=ALL]\n:");
  127.                                             Getstring(newitem->To,0,20,0,0);
  128.                                             if (strlen(newitem->To))
  129.                                             {
  130.                                                 if ((newitem->ToUser = SearchUser(newitem->To)))
  131.                                                 {
  132.                                                     strncpy(newitem->To,            cport->UL.utable[newitem->ToUser].Handle,sizeof(newitem->To)-1);
  133.                                                     strncpy(newitem->ToRealName,cport->UL.utable[newitem->ToUser].RealName,sizeof(newitem->ToRealName)-1);
  134.                                                     quit = TRUE;
  135.                                                 }
  136.                                                 else
  137.                                                 {
  138.                                                     ioprintf("%s is not a user of this system. use anyway ?");
  139.                                                     if (Yesno(FALSE,0))
  140.                                                         quit = TRUE;
  141.                                                 }
  142.                                             }
  143.                                             else
  144.                                                 quit = TRUE;
  145.                                         }
  146. //                                        MailListMail
  147. //                                        MailListID
  148.                                         ioprintf("errror: %d\n",ndos_addmail(newitem));
  149.                                     }
  150.                                     FreeVec(newitem->text);
  151.                                 }
  152.                                 FreeVec(newitem);
  153.                             }
  154.                         }
  155.                         Close(mulder);
  156.                     }
  157.                 }
  158.             }
  159.             return TRUE;
  160.             break;
  161.         case CMD_SUBBOARD_NEW:
  162.             {
  163.                 Directory *dir;
  164.                 if ((dir = ndos_mkdir(cport->argptr)))
  165.                 {
  166.                     ioprintf("directory %s created.\n",cport->argptr);
  167.                     ndos_closedir(dir);
  168.                 }
  169.             }
  170.             return TRUE;
  171.             break;
  172.         case CMD_PARRENT:
  173.             ndos_parrentdir();
  174.             return TRUE;
  175.             break;
  176.         case CMD_DIR:
  177.             ndos_execute("novia:sbin/list");
  178.             return TRUE;
  179.             break;
  180.         case CMD_PORTOPEN:
  181.             if (cport->systemservice)
  182.             {
  183.                 UBYTE *table;
  184.                 UBYTE invalid=TRUE;
  185.                 if ((table=AllocVec(10000,MEMF_ANY|MEMF_CLEAR)))
  186.                 {
  187.                     SelectFromTo(table+1,9999,cport->argstring[1]);
  188.                     nc=(PortData2 *)client_list->lh_Head;
  189.                     while (nc->port_node.ln_Succ)
  190.                     {
  191.                         if (table[nc->port_address->clientconfig.IDNumber])
  192.                         {
  193.                             cport2=nc->port_address;
  194.                             Writeio("loadport: ",-1);
  195.                             Writelong(cport2->clientconfig.IDNumber);
  196.                             LF();
  197.                             if (cport2->PortStatus==PORT_STATUS_CLOSE)
  198.                             {
  199.                                 cport2->PortStatus=PORT_STATUS_WAITLOAD;
  200.                                 CreateClient(cport2);
  201.                             }
  202.                             else
  203.                             {
  204.                                 SendMsg(cport2->LocalPort,0,0,MSG_PORT_TOFRONT,0);
  205.                             }
  206.                             invalid=FALSE;
  207.                         }
  208.                         nc=(PortData2 *)nc->port_node.ln_Succ;
  209.                     }
  210.                     if (invalid)
  211.                     {
  212.                         ioprintf("USAGE: OpenPort #IDNumber(s)\n");
  213.                         ioprintf("    Example: OP 1-3,8-,5  (Open Port 1,2,3,5,8 and all other Ports higher 8.)\n");
  214.                     }
  215.                     FreeVec(table);
  216.                 } 
  217.                 return TRUE;
  218.             }
  219.             break;
  220.         case CMD_PORTCLOSE:
  221. /*            if (cport->systemservice)
  222.             {
  223.                 UBYTE *table;
  224.                 UBYTE invalid=TRUE;
  225.                 if ((table=AllocVec(10000,MEMF_ANY|MEMF_CLEAR)))
  226.                 {
  227.                     SelectFromTo(table+1,9999,cport->argstring[1]);
  228.                     nc=(PortData2 *)client_list->lh_Head;
  229.                     while (nc->port_node.ln_Succ)
  230.                     {
  231.                         if (table[nc->port_address->clientconfig.IDNumber])
  232.                         {
  233.                             cport2 = nc->port_address;
  234.                             Writeio("loadport: ",-1);
  235.                             Writelong(cport2->clientconfig.IDNumber);
  236.                             LF();
  237.                             if (ulong! = cport->clientconfig.IDNumber)
  238.                                 CloseClientPort(ulong);
  239.                             else
  240.                                 ioprintf("You can't close your own port.\n");
  241.                             invalid=FALSE;
  242.                         }
  243.                         nc=(PortData2 *)nc->port_node.ln_Succ;
  244.                     }
  245.                     if (invalid)
  246.                     {
  247.                         ioprintf("USAGE: ClosePort #IDNumber(s)\n");
  248.                         ioprintf("    Example: OP 1-3,8-,5  (Open Port 1,2,3,5,8 and all other Ports higher 8.)\n");
  249.                     }
  250.                     FreeVec(table);
  251.                 } 
  252.                 return TRUE;
  253.             }    */
  254.             if (cport->systemservice)
  255.             {
  256.                 ULONG PortID;
  257.                 StrToLong(cport->argstring[1],(LONG *)&PortID);
  258.                 ioprintf("closeport: %d\n",PortID);
  259.                 if (PortID != cport->clientconfig.IDNumber)
  260.                     CloseClientPort(PortID);
  261.                 else
  262.                     ioprintf("You can't close your own port.\n");
  263.                 return TRUE;
  264.             }
  265.             break;
  266.         case CMD_NEWPORT:
  267.             if (cport->systemservice)
  268.             {
  269.                 NewClientPort();
  270.                 return TRUE;
  271.             }
  272.             break;                            
  273.         case CMD_PORTREMOVE:
  274.             if (cport->systemservice)
  275.             {
  276.                 return TRUE;
  277.             }
  278.             break;
  279.         case CMD_RESETBBS:
  280.             if (cport->systemservice)
  281.             {
  282.                 return TRUE;
  283.             }
  284.             break;
  285.         case CMD_EDITCONFIG:
  286.             if (cport->systemservice)
  287.             {
  288. /*                struct MainPortConfig *config2;
  289.                 if (config2=AllocVec(sizeof(MainPortConfig),MEMF_ANY|MEMF_CLEAR))
  290.                 {
  291.                     CopyMemQuick(mainportconfig,config2,sizeof(MainPortConfig));
  292.                     if (VDE(VDEID_MAINPORTCONFIG,(char *)config2))
  293.                     {
  294.                         if ((config2->ScreenMode!=mainportconfig->ScreenMode)|
  295.                             (config2->CH_Main!=mainportconfig->CH_Main)|
  296.                             (config2->Colors!=mainportconfig->Colors)|
  297. //                            (config2->FontName!=mainportconfig->FontName)|
  298.                             (config2->Fontsize!=mainportconfig->Fontsize)|
  299. //                            (config2->TermFontName!=mainportconfig->TermFontName)|
  300.                             (config2->TermFontsize!=mainportconfig->TermFontsize))
  301.                         {
  302.                             cport->clientconfig.ScreenModeID=config2->ScreenMode;
  303.                             cport->clientconfig.Colors=config2->Colors;
  304.                             CopyMem(cport->clientconfig.ScreenFont,config2->FontName,32);
  305.                             cport->clientconfig.ScreenFontsize=config2->Fontsize;
  306.                             CopyMem(cport->clientconfig.TermFont,config2->TermFontName,32);
  307.                             cport->clientconfig.TermFontsize=config2->TermFontsize;
  308.                             Monitor_close();
  309.                             Monitor_open();
  310.                         }
  311.                         CopyMemQuick(config2,mainportconfig,sizeof(MainPortConfig));
  312.                         SaveMainPortConfig(mainportconfig);
  313.                     }
  314.                     FreeVec(config2);
  315.                 }
  316.                 else
  317.                     ioprintf("Not anouth memory to edit mainport.config.\n");
  318.                 return TRUE;*/
  319.                 execute_nsl("novia:scripts/edit_mainconfig.nsl");
  320.             }
  321.             break;
  322.         case CMD_EDITCLIENT:
  323.             if (cport->systemservice)
  324.             {
  325.                 StrToLong(cport->argstring[1],(LONG *)&ulong);
  326.                 if (ulong && (cport2=FindClient(ulong)))
  327.                 {
  328. /*                    if (VDE(VDEID_CLIENTCONFIG,(char *)cport2))
  329.                     {
  330.                         SaveClientConfig(&cport2->clientconfig);
  331.                     }*/
  332.                 }
  333.                 else
  334.                 {
  335.                     ioprintf("USAGE: OpenPort [#IDNumber|ALL]\n");
  336.                 }
  337.                 return TRUE;
  338.             }
  339.             break;
  340.         case CMD_LOGIN:
  341.             ioprintf("\nLogin Username:> ");
  342.             Getstring(buffer,0,20,0,0);
  343.             if ((ulong=SearchUser(buffer)))
  344.             {
  345.                 ndos_saveselectlist((List *)&cport->select_list);
  346.                 ioprintf("load user\n");
  347.                 LoadUser(&cport->LocalUser,ulong);
  348.  
  349.                 ioprintf("\nPassword      :> ");
  350.                 ioprintf("\nCurrent User is :%s (%d)\n",cport->LocalUser.Handle,ulong);
  351.                 ndos_loadselectlist((List *)&cport->select_list);
  352.                 ndos_getlist();
  353.             }
  354.             else
  355.             {
  356.                 ioprintf("\nunknown User: %s \n",buffer);
  357.             }
  358.             return TRUE;
  359.             break;
  360.         case CMD_IDENTIFY:
  361.             if (cport->LocalUser.Flag_supervisor)
  362.             {
  363.                 ioprintf("\nPassword :> ");
  364.                 ioprintf("\nEncrypt  :> \n\n");
  365.                 ioprintf("system services commands now available.\n");
  366.                 cport->systemservice=TRUE;
  367.                 return TRUE;
  368.             }
  369.             break;
  370.         case CMD_PING:
  371.             StrToLong(cport->argstring[1],(LONG *)&ulong);
  372.             cport2=FindClient(ulong);
  373.             if (cport2)
  374.             {
  375.                 if (cport2->PortStatus>0)
  376.                 {
  377.                     ULONG ticks;
  378.                     timeval tv;
  379.                     double double1;
  380.                     double double2;
  381.                     struct EClockVal eclock;
  382.                     struct EClockVal eclock2;
  383.                     ReadEClock(&eclock);
  384.                     SendMsg(cport2->LocalPort,0,0,MSG_PING,0);
  385.                     Wait(1<<cport->MainPort->mp_SigBit);
  386.                     ticks=ReadEClock(&eclock2)/1000;
  387.                     double1=(double)eclock.ev_lo;
  388.                     double2=(double)eclock2.ev_lo;
  389.  
  390.                     ioprintf("\n%d, bytes from %d: time=%f ms\n",sizeof(message),cport2->clientconfig.IDNumber,(double2-double1)/(double)ticks);
  391.                 }
  392.             }
  393.             return TRUE;
  394.             break;
  395.         case CMD_JOIN:
  396.             if (cport==mport)
  397.             {
  398.                 EditNRCList(nrcserver->roomlist);
  399.             }
  400.             else
  401.                 OpenConference();
  402.             return TRUE;
  403.             break;
  404.         case CMD_SHELL:
  405. //            NewShell();
  406.             break;
  407.         case CMD_CONFIG:
  408.             if (cport->argcounter==0)
  409.             {
  410.                 Writeio("Usage: CONFIG COMMAND|MENU...\n\n",-1);
  411.             }
  412.             else
  413.             {
  414. /*                if (!stricmp(cport->argstring[1],"COMMAND"))
  415.                     VDEEditCommandList();*/
  416.             }            
  417.             return TRUE;
  418.             break;
  419.         case CMD_CLOSEGUI:
  420.             if (cport->systemservice)
  421.             {
  422.                 if (progtype==NOVIA_MAIN)
  423.                 {
  424.                     if (guifrontend.GUIOpen && GUITask)
  425.                     {
  426.                         guifrontend.ProgramClose=TRUE;
  427.                         Signal(GUITask,GUITask->tc_SigWait);
  428.                         ioprintf("wait for closeing GUI Sig\n");
  429.                         while (guifrontend.GUIOpen)
  430.                         {
  431.                             Delay(5);
  432.                         }
  433.                     }
  434.                 }
  435.                 else
  436.                     ioprintf("GUI can't close from remote Port.\n");
  437.                 return TRUE;
  438.             }
  439.             break;
  440.         case CMD_LOADGUI:
  441.             if (cport->systemservice)
  442.             {
  443.                 if (progtype==NOVIA_MAIN)
  444.                 {
  445.                     StartGUI();
  446.                 }
  447.                 else
  448.                     ioprintf("GUI can't open from remote Port.\n");
  449.                 return TRUE;
  450.             }
  451.             break;
  452.         case CMD_LOGOFF:
  453.             if (progtype==NOVIA_CLIENT)
  454.             {
  455.                 ClearMemQuick(&cport->LocalUser,sizeof(UserData));
  456.                 ClearMemQuick(&cport->EditUser,sizeof(UserData));
  457.                 cport->systemservice=FALSE;
  458.                 ioprintf("\nc7%s c3logged off\n",cport->LocalUser.Handle);
  459.             }
  460.             else
  461.                 ioprintf("This is a client command.\n");
  462.             return TRUE;
  463.             break;
  464.         case CMD_QUIT:
  465.             if (progtype==NOVIA_CLIENT)
  466.             {
  467.                 ClearMemQuick(&cport->LocalUser,sizeof(UserData));
  468.                 ClearMemQuick(&cport->EditUser,sizeof(UserData));
  469.                 cport->systemservice=FALSE;
  470.                 ioprintf("\nc7%s c3logged off\n",cport->LocalUser.Handle);
  471.                 cport->PortStatus=PORT_STATUS_WAITCALL;
  472.                 cport->network.online=FALSE;
  473.             }
  474.             else
  475.             {
  476.                 if (cport->systemservice)
  477.                 {
  478.                     cport->ProgramClose=TRUE;
  479.                     cport->network.online = FALSE;
  480.                 }
  481.             }
  482.             return TRUE;
  483.             break;
  484.         case CMD_EDITACCOUNT:
  485.             if (cport->systemservice)
  486.             {
  487.                 if (ulong=FindUser(cport->argstring[1]))
  488.                     UserEdit(ulong);
  489.                 return TRUE;
  490.             }
  491.             break;
  492.         case CMD_EDITFILE:
  493.             if (cport->systemservice)
  494.             {
  495.                 if (strlen(cport->argstring[1]))
  496.                 {
  497. //                    VisualEditor(cport->argstring[1]);
  498.                 }
  499.                 else
  500.                 {
  501.                     Writeio("Usage: EDITFILE filename\n",-1);
  502.                     LF();
  503.                 }
  504.                 return TRUE;
  505.             }
  506.             break;
  507.         case CMD_SENDMAIL:
  508.             ioprintf("NOViA MailSend ©1997-1999 by Campino/UFoP\n");
  509.             if (cport->LocalUser.Flag_send_email | cport->LocalUser.Flag_supervisor)
  510.             {
  511. /*                if (strlen(cport->argstring[1]))
  512.                 {
  513.                     NewMail *newmail;
  514.                     if ((newmail = AllocVec(sizeof(NewMail),MEMF_ANY|MEMF_CLEAR)))
  515.                     {
  516.                         if (!(newmail->ToUser = SearchUser(cport->argstring[1])))
  517.                         {
  518.                             BOOL uucp = FALSE;
  519.                             char *ptr = cport->argstring[1];
  520.                             while (*ptr && !uucp)
  521.                                 if (*ptr++ == '@') uucp = TRUE;
  522.                             if (uucp)
  523.                             {
  524.                                 UWORD strlength = strlen(cport->argstring[1]);
  525.                                 if ((newmail->To = AllocVec(strlength + 1,MEMF_ANY)))
  526.                                     strncpy(newmail->To, cport->argstring[1], sizeof(newmail->To)-1);
  527.                             }
  528.                         }
  529.                         if (newmail->ToUser || newmail->To)
  530.                         {
  531.                             ULONG strlength;
  532.                             ioprintf("Enter Subject:");
  533.                             Getstring(newmail->subject,0,60,0,0);
  534.                             ioprintf("Write as an alias ? y/[N]");
  535.                             if (Yesno(FALSE,0))
  536.                             {
  537.                                 ioprintf("Enter alias:");
  538.                                 Getstring(newmail->Alias,0,60,0,0);
  539.                             }
  540.                             ioprintf("CC:");
  541.                             Getstring(buffer,0,60,0,0);
  542.                             strlength = strlen(buffer);
  543.                             if (strlength >1)
  544.                             {
  545.                                 if (!(newmail->CCUser = SearchUser(buffer)))
  546.                                 {
  547.                                     char *ptr = buffer;
  548.                                     BOOL uucp = FALSE;
  549.                                     while (!uucp && *ptr && *ptr != '@')
  550.                                         ptr++;
  551.                                     if (*ptr == '@')
  552.                                     {
  553.                                         if ((newmail->CC = AllocVec(strlength + 1,MEMF_ANY)))
  554.                                             strncpy(newmail->CC, buffer, sizeof(newmail->CC)-1);
  555.                                     }
  556.                                 }
  557.                             }
  558.                             ioprintf("BCC:");
  559.                             Getstring(buffer,0,60,0,0);
  560.                             strlength = strlen(buffer);
  561.                             if (strlength >1)
  562.                             {
  563.                                 if (!(newmail->BCCUser = SearchUser(buffer)))
  564.                                 {
  565.                                     char *ptr = buffer;
  566.                                     BOOL uucp = FALSE;
  567.                                     while (!uucp && *ptr && *ptr != '@')
  568.                                         ptr++;
  569.                                     if (*ptr == '@')
  570.                                     {
  571.                                         if ((newmail->BCC = AllocVec(strlength + 1,MEMF_ANY)))
  572.                                             strncpy(newmail->BCC, buffer,sizeof(newmail->BCC)-1);
  573.                                     }
  574.                                 }
  575.                             }
  576.                             ioprintf("Importance ? low/normal/high");
  577.                             GetChar(buffer,0);
  578.                             if (*buffer == 'l' | *buffer == 'L')
  579.                                 newmail->importance = MAIL_IMPORTANCE_LOW;
  580.                             else
  581.                             {
  582.                                 if (*buffer == 'h' | *buffer == 'H')
  583.                                     newmail->importance = MAIL_IMPORTANCE_HIGH;
  584.                                 else
  585.                                     newmail->importance = MAIL_IMPORTANCE_NORMAL;
  586.                             }
  587.                             ioprintf("Copy Mail to your own Mailbox ? y/[N]");
  588.                             if (Yesno(FALSE,0))
  589.                                 newmail->copy_own = TRUE;
  590.                             VisualEditor("ram:temp");
  591.                             ioprintf("%d\n",uucp_sendmail(newmail));
  592.                         }
  593.                         FreeVec(newmail);
  594.                     }
  595.                     else
  596.                     {
  597.                         ioprintf("ERROR: out of memory.\n");
  598.                     }
  599.                 }
  600.                 else
  601.                 {
  602.                     ioprintf("Usage: MS username|usernumber\n");
  603.                 }
  604. */
  605.                 VisualEditor("ram:test",0,VISUALEDIT_FILE);
  606.             }
  607.             else
  608.             {
  609.                 ioprintf("\nYour are can't write mails.\n");
  610.             }
  611.             return TRUE;
  612.             break;
  613.         case CMD_MAILVERIFY:
  614.             ulong=SearchUser(cport->argstring[1]);
  615.             if (ulong==0)
  616.             {
  617.                 LF();ioprintf("NOViA MailVerify ©1997-1999 by Thorsten Gehler/UFoP\n");
  618.                 ioprintf("Usage: MV username|usernumber\n");
  619.             }
  620. //            else
  621. //                MailVerify(ulong);
  622.             return TRUE;
  623.             break;
  624.         case CMD_STATUS:
  625.             if (cport==mport)
  626.             {
  627.                 nc=(PortData2 *)client_list->lh_Head;
  628.                 ioprintf("\n");
  629.                 while (nc->port_node.ln_Succ)
  630.                 {
  631.                     cport2=nc->port_address;
  632.                     ioprintf("PortNo: %d, Handle: %s, status: %s\n",cport2->clientconfig.IDNumber,cport2->LocalUser.Handle,getstr(60,(UWORD)cport2->PortStatus));
  633.                     nc=(PortData2 *)nc->port_node.ln_Succ;
  634.                 }
  635.                 return TRUE;
  636.             }
  637.             else
  638.             {
  639.                 LF();
  640.                 Writeio("IDNumber : ",-1);Writelong(cport->LocalUser.IDNumber);LF();
  641.                 Writeio("IPNumber : ",-1);Writelong(cport->LocalUser.IPNumber);LF();
  642.                 Writeio("Handle   : ",-1);ioprintf("%s\n",cport->LocalUser.Handle);
  643.                 Writeio("Password : ",-1);ioprintf("%s\n",cport->LocalUser.PassWord);
  644.                 Writeio("PWEncrypt: ",-1);ioprintf("%s\n",cport->LocalUser.PassWordEncrypt);
  645.                 LF();
  646.                 ioprintf("Press a key to continue.\n");
  647.                 WaitKey(0);
  648.             }
  649.             return TRUE;
  650.             break;
  651.         case CMD_READMAIL:
  652.             if (cport->LocalUser.Flag_read_priv_msg|cport->LocalUser.Flag_supervisor)
  653.             {
  654. //                MailVerify(cport->LocalUser.IDNumber);
  655. //                GetINETMail();
  656.                 return TRUE;
  657.             }
  658.             break;
  659.         case CMD_SHOWUSERLIST:
  660.             if (cport->LocalUser.Flag_use_userlist|cport->LocalUser.Flag_supervisor)
  661.             {
  662.                 ShowUserList();
  663.                 return TRUE;
  664.             }
  665.             else
  666.             {
  667.                 ioprintf("\nSorry. You're can't use this command.\n");
  668.             }
  669.             break;        
  670.         case CMD_OLM:
  671.             SendOnlineMessage(cport);
  672.             return TRUE;
  673.             break;
  674.         case CMD_USERINFO:
  675.             LF();
  676.             ulong=SearchUser(cport->argstring[1]);
  677.             if (ulong>0)
  678.             {
  679.                 if (LoadUser(&cport->EditUser,ulong)==TRUE)
  680.                 {
  681.                     sprintf(buffer,"%ssys.userinfo",cport->sysdirs->systext);
  682.                     ShowText(buffer);
  683.                     ioprintf("Press a key to continue\n");
  684.                     WaitKey(0);
  685.                     return TRUE;
  686.                 }
  687.             }
  688.             Writeio("Unknown User: ",-1);
  689.             ioprintf("%s\n",cport->argstring[1]);
  690.             ioprintf("Usage: Userinfo [Username|Usernumber]\n");
  691.             return TRUE;
  692.             break;
  693.         case CMD_WHO:
  694.             if (cport==mport)
  695.             {
  696. /*                struct PortData2 *clientport;
  697.                 struct PortData *cport2;
  698.                 char *txtptr=AllocVec(1000,MEMF_ANY|MEMF_CLEAR);
  699.                 if (txtptr=AllocVec(1000,MEMF_ANY|MEMF_CLEAR))
  700.                 {
  701.                     sprintf(txtptr,"Port Username            Logon  Spd From                Where        \n");
  702.                     txtptr=txtptr+strlen(txtptr);
  703.                     sprintf(txtptr,"==== =================== ====== === =================== =============\n");
  704.                     txtptr=txtptr+strlen(txtptr);
  705.                     clientport=(PortData2 *)client_list->lh_Head;
  706.                     while (clientport->port_node.ln_Succ)
  707.                     {
  708.                         cport2=clientport->port_address;
  709.                         sprintf(buffer,"%4d %-19s %2d:%02d  %3d %-19s %s\n",
  710.                             cport2->clientconfig.IDNumber,
  711.                             cport2->LocalUser.Handle,
  712.                             cport2->LastLogin.hours,
  713.                             cport2->LastLogin.mins,
  714.                             cport2->CurrentCPS,
  715.                             cport2->LocalUser.City,
  716.                             cport2->Where);
  717.                         strcpy(txtptr,buffer);
  718.                         txtptr=txtptr+strlen(buffer);
  719.                         clientport=(PortData2 *)clientport->port_node.ln_Succ;
  720.                     }
  721.                     ioprintf(txtptr,-1);
  722.                     FreeVec(txtptr);
  723.                 }*/
  724.                 startrexxprg("rexxc:noviatest.rexx");
  725.             }
  726.             else
  727.             {
  728.                 ioprintf("Your User: %d from %s\n",cport->clientconfig.IDNumber,cport->whostring);
  729.                 SendMsg(cport->MainPort,0,0,MSG_COMMAND,CMD_WHO);
  730.             }
  731.             return TRUE;
  732.             break;
  733.         case CMD_REPAIR:
  734. //            RepairUserList(&cport->UL);
  735.             ioprintf("cport: %x\n",cport);
  736.             {
  737.                 char buffer[100];
  738.                 sprintf(buffer,"mcpp:/novia/convert %d",cport);
  739.                 Execute(buffer,(BPTR)NULL,NULL);
  740.             }
  741.             return TRUE;
  742.             break;
  743.         case CMD_EDIT:
  744.             ndos_editflags(cport->argptr);
  745.             return TRUE;
  746.             break;
  747.         case CMD_VIEWSELECTLIST:
  748.             {
  749.                 struct SelectItem *select = (SelectItem *)cport->select_list.mlh_Head;
  750.                 struct Item item;
  751.                 while (select->ln_Succ)
  752.                 {
  753. //                    if (GetItem_byIP(select->dirIP,select->itemIP,&item,sizeof(ItemHeader)));
  754.                         ioprintf("selected\n");
  755. //                        ioprintf("%-40d\n",item.itemheader.Title);
  756.                     select = select->ln_Succ;
  757.                 }
  758.             }
  759.             return TRUE;
  760.             break;
  761.         case CMD_DOWNLOAD_SELECT:
  762.             {
  763.                 char quit = 0;
  764.                 struct Select *select=(Select *)cport->select_list.mlh_Head;
  765.                 while (quit<1 && select->ln_Succ)
  766.                 {
  767.                     ioprintf("download: (%s)%-40s ([Yes],No,All,Cancel,Quit) ? ",select->dirpath,select->filepath);
  768.                     switch (AskKey(RESULT_YES , FLAG_YES | FLAG_NO | FLAG_ALL | FLAG_CANCEL | FLAG_QUIT , 0))
  769.                     {
  770.                         case RESULT_YES:
  771.                             select->downloadnow=TRUE;
  772.                             break;
  773.                         case RESULT_NO:
  774.                             select->downloadnow=FALSE;
  775.                             break;
  776.                         case RESULT_ALL:
  777.                             while (select->ln_Succ)
  778.                             {
  779.                                 select->downloadnow=TRUE;
  780.                                 select=select->ln_Succ;
  781.                             }
  782.                             quit=1;
  783.                             break;
  784.                         case RESULT_CANCEL:
  785.                             while (select->ln_Succ)
  786.                             {
  787.                                 select->downloadnow=FALSE;
  788.                                 select=select->ln_Succ;
  789.                             }
  790.                             quit=1;
  791.                             break;
  792.                         case RESULT_QUIT:
  793.                             select=(Select *)cport->select_list.mlh_Head;
  794.                             while (select->ln_Succ)
  795.                             {
  796.                                 select->downloadnow=FALSE;
  797.                                 select=select->ln_Succ;
  798.                             }
  799.                             quit=2;
  800.                             break;
  801.                     }
  802.                     select=select->ln_Succ;
  803.                 }
  804.                 if (quit == 1)
  805.                 {
  806.                     ioprintf("do transfer\n");
  807.                     if (!IsListEmpty((List *)&cport->select_list))
  808.                     {
  809.                         struct SelectItem *select=(SelectItem *)cport->select_list.mlh_Head;
  810.                         char quit=FALSE;
  811.                         cport->actual = NULL;                            // reset actual download file
  812.                         while (select->ln_Succ && !quit)
  813.                         {
  814.                             if (select->downloadnow)
  815.                             {
  816.                                 cport->actual = select;                    // set first file to download
  817.                                 quit = TRUE;
  818.                             }
  819.                             select=select->ln_Succ;
  820.                         }
  821.                     }
  822.                     else
  823.                         ioprintf("no files to download\n");
  824.                 }
  825.                     
  826.                 if (IsListEmpty((List *)&cport->select_list))
  827.                     ioprintf("You have no no files selected\n");
  828.                 else
  829.                     DoTransfer();
  830.  
  831.             }
  832.             return TRUE;
  833.             break;
  834.     }
  835.     return NULL;
  836. }